<?php
/**
 * Created by PhpStorm.
 * User: qishengqiang
 * Date: 2022-07-06
 * Time: 11:14
 */

namespace app\admin\controller;


use app\admin\BaseController;
use app\models\Universities;

class UniversityController extends BaseController
{
    public function indexAction()
    {
        $get = $this->request->get();

        if (isset($get['keywords'])) {
            $params['where'][] = [
                'universityName', 'like', '%'.$get['keywords'].'%'
            ];
        }

        $params['order'] = ['cityCode' => 'asc'];

        $data['lists'] = [];

        $universities = Universities::lists($params, $this->page, $this->pagesize);

        if (count($universities)) {
            foreach ($universities as $university) {
                $data['lists'][] = [
                    'universityId' => $university->universityId,
                    'universityName' => $university->universityName,
                    'arrangement' => $university->arrangement,
                ];
            }
        }

        $data['totalInfo'] = $this->app->utilService->getMeta($universities);

        return json()->data(['code' => 200, 'msg' => '操作成功', 'data' => $data]);
    }
}